// |------------------------------------------------------
// |------------------------------------------------------
// | Common mixins
// |------------------------------------------------------
// |------------------------------------------------------

@mixin _gridle_container_common(
	$state : default
) {
	@extend %gridle-simple-clearfix;
	@extend %gridle-container-common;
	// debug part
	$debug : _gridle_get_var_value(debug, $state);
	@if ($debug == true) {
		#{$gridle-debug-selector} {
			@extend %gridle-container-debug-common;
		}
	}
}
$_gridle-already-generated : ();
@mixin _gridle_grid_common() {
	@extend %gridle-grid-common;

	// default values
	$default-gutter-width : _gridle_get_var_value(gutter-width, default);
	$default-direction : _gridle_get_var_value(direction, default);

	// loop on each states :
	@each $stateName, $state in $_gridle-states
	{
		// selector key to be used in map
		$key : "#{$stateName} #{&}";

		// check if already generated classes
		$already-generated : map-has-key($_gridle-already-generated, $key);

		// vars
		$direction : _gridle_get_var_value(direction, $state);
		$classes : _gridle_get_var_value(classes, $state);
		$gutter-width : _gridle_get_var_value(gutter-width, $state);
		$debug : _gridle_get_var_value(debug, $state);

		@if $already-generated != true and $classes and ( ($default-direction != $direction or $default-gutter-width != $gutter-width) or $stateName == default)
		{
			// set that we have already generated css for this selector
			$_gridle-already-generated : map-set($_gridle-already-generated, $key, true) !global;
			
			// generate the css for this element
			@include gridle_state($state) {
				@if $direction != $default-direction or $stateName == default {
					// content : "#{$key}";
					@if $direction == rtl {
						float:right;
						direction:rtl;
					} @else {
						float:left;
						direction:ltr;
					}
				}
				@if $gutter-width != $default-gutter-width or $stateName == default {
					padding-left:$gutter-width/2;
					padding-right:$gutter-width/2;
				}
			}
			
			@if $debug == true {
				#{$gridle-debug-selector} {
					@extend %gridle-grid-debug-common;
				}
			}
		}
	}
}
@mixin _gridle_parent_common() {
	@extend %gridle-clearfix;
	@extend %gridle-parent-common;
}
@mixin _gridle_push_common(
	$state : default
) {
	$debug : _gridle_get_var_value(debug, $state);

	// extend common :
	@extend %gridle-push-pull-common;
	@if $debug == true {
		#{$gridle-debug-selector} {
			@extend %gridle-push-pull-debug-background-common;
			background-color:#f4efdf !important;
		}
	}
}
@mixin _gridle_pull_common(
	$state : default
) {
	$debug : _gridle_get_var_value(debug, $state);

	@extend %gridle-push-pull-common;
	@if $debug == true {
		#{$gridle-debug-selector} {
			@extend %gridle-push-pull-debug-background-common;
			background-color:#cfe4d5 !important;
		}
	}
}
@mixin _gridle_prefix_common(
	$state : default
) {
	$debug : _gridle_get_var_value(debug, $state);
	@if $debug == true {
		#{$gridle-debug-selector} {
			@extend %gridle-prefix-debug-common;
		}
	}
}
@mixin _gridle_suffix_common(
	$state : default
) {
	$debug : _gridle_get_var_value(debug, $state);
	@if $debug == true {
		#{$gridle-debug-selector} {
			@extend %gridle-suffix-debug-common;
		}
	}
}